package pen_exam.xieceng_2023_11_20;

import java.util.Scanner;

public class Class02_MaxFruit {
    public static void main(String[] args) {
        Scanner  sc = new Scanner(System.in);
        String[] s = sc.nextLine().split(" ");
        int n = Integer.parseInt(s[0]) ;//苹果
        int m = Integer.parseInt(s[1]); //桃子
        int x = Integer.parseInt(s[2]); //套餐A 2a1p
        int y = Integer.parseInt(s[3]); //套餐B 1a2p
        int a = Math.min(n/2,m);//套餐A最大数量
        int b = Math.min(n,m/2);//套餐B最大数量
        if(a == 0 && b == 0 ){
            System.out.print(0);
        }else if(a == 0){
            System.out.print(b * y);
        }else if(b == 0){
            System.out.print(a * x);
        }else{
            System.out.println(func(n,m,x,y,a,b));
        }
    }
    public static int func(int n,int m,int x,int y,int a,int b){
        int rest = 0;
        if(a < b){
            for (int i = 0; i < a; i++) {
                n -= 2*i;
                m -= i;
                int p1 = i * x;
                int p2 = Math.min(0,(Math.min(n,m/2)))  * y;
                rest = Math.max(rest,(p1 + p2));
                n += 2*i;
                m += i;
            }
            return rest;
        }else{
            for (int i = 0; i < b; i++) {
                n -= i;
                m -= 2 * i;
                int p1 = i * y;
                int p2 = Math.min(0,(Math.min(n/2,m)))  * x;
                rest = Math.max(rest,(p1 + p2));
                n += i;
                m += 2* i;
            }
            return rest;
        }

    }
}
